#include"RQueue.hpp"
#include<unistd.h>
#include<ctime>
void*productor(void*args)
{
    RQueue<int>*ps = static_cast<RQueue<int>*>(args);
    while(true)
    {

        int date = rand()%10 + 1;
        ps->push(date);
        cout<<"productor a date:"<<date<<endl;
    }
}
void*consumer(void*args)
{
    sleep(3);//前三秒没有消费；
    RQueue<int>*ps = static_cast<RQueue<int>*>(args);
    while(true)
    {
        int date = ps->pop();
		cout<<"consumer a date:"<<date<<endl; 
        sleep(1);
    }
}
int main()
{
    pthread_t p,c;
    RQueue<int>*ptr = new RQueue<int>;
    ptr->Init();
    pthread_create(&p,nullptr,productor,ptr);
    pthread_create(&c,nullptr,consumer,ptr);
    while(true)
    {
        ;
    }
    return 0;
}
